/**
 * Created by wenguangjia on 2017/5/31.
 */
(function () {
    'use strict';

    angular
        .module('logcenterApp')
        .config(stateConfig);

    stateConfig.$inject = ['$stateProvider'];

    function stateConfig($stateProvider) {
        $stateProvider
            .state('logarchive', {
                parent: 'app',
                url: '/log/archive',
                data: {
                    authorities: ['ROLE_ADMIN']
                },
                views: {
                    'content@': {
                        templateUrl: 'app/logconfig/logarchive/logarchive.html',
                        controller: 'logarchiveController',
                        controllerAs: 'vm'
                    }
                },
                resolve: {
                    translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
                        $translatePartialLoader.addPart('global');
                        return $translate.refresh();
                    }],
                    locations: getLocations
                }
            })
            .state('partition', {
                parent: 'app',
                url: '/log/partition',
                data: {
                    authorities: ['ROLE_ADMIN']
                },
                views: {
                    'content@': {
                        templateUrl: 'app/logconfig/partitionConfig/partitionConfig.html',
                        controller: 'partitionConfigController',
                        controllerAs: 'vm'
                    }
                },
                resolve: {
                    translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
                        $translatePartialLoader.addPart('global');
                        return $translate.refresh();
                    }]
                }
            })
            .state('esstatus', {
                parent: 'app',
                url: '/log/estatus',
                data: {
                    authorities: ['ROLE_ADMIN']
                },
                views: {
                    'content@': {
                        templateUrl: 'app/logconfig/esStatus/esStatus.html',
                        controller: 'esStatusController',
                        controllerAs: 'vm'
                    }
                },
                resolve: {
                    translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
                        $translatePartialLoader.addPart('global');
                        return $translate.refresh();
                    }]
                }
            })
            .state('esclusterconfig', {
                parent: 'app',
                url: '/log/esclusterconfig',
                data: {
                    authorities: ['ROLE_ADMIN']
                },
                views: {
                    'content@': {
                        templateUrl: 'app/logconfig/esClusterConfig/esClusterConfig.html',
                        controller: 'esClusterConfigController',
                        controllerAs: 'vm'
                    }
                },
                resolve: {
                    translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
                        $translatePartialLoader.addPart('global');
                        return $translate.refresh();
                    }]
                }
            })
            .state('esindex', {
                parent: 'app',
                url: '/log/esindex',
                data: {
                    authorities: ['ROLE_ADMIN']
                },
                views: {
                    'content@': {
                        templateUrl: 'app/logconfig/esIndex/esIndex.html',
                        controller: 'esIndexController',
                        controllerAs: 'vm'
                    }
                },
                resolve: {
                    translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
                        $translatePartialLoader.addPart('global');
                        return $translate.refresh();
                    }]
                }
            })
            .state('filebeatConfig', {
                parent: 'app',
                url: '/log/filebeatConfig',
                data: {
                    authorities: ['ROLE_ADMIN']
                },
                views: {
                    'content@': {
                        templateUrl: 'app/logconfig/filebeatConfig/filebeatConfig.html',
                        controller: 'filebeatConfigController',
                        controllerAs: 'vm'
                    }
                },
                resolve: {
                    translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
                        $translatePartialLoader.addPart('global');
                        return $translate.refresh();
                    }]
                }
            })

    }

    getLocations.$inject=['PropertiesService'];
    function getLocations(PropertiesService) {
        return PropertiesService.getProperties().then(function (promiseValue) {
            return promiseValue.locations;
        });
    }

})();
